package com.wxit.algorithm.tree;

/**
 * 翻转二叉树
 */
public class LeetCode226 {

    public static void main(String[] args) {

    }

    public TreeNode invertTree(TreeNode root) {
        fn(root);
        return root;
    }

    private static void fn(TreeNode root) {
        if (root == null) {
            return;
        }
        TreeNode t = root.left;
        root.left = root.right;
        root.right = t;
        fn(root.left);
        fn(root.right);
    }
}
